package router

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
	"tuowei.com/app/api/apis"
	"tuowei.com/common/actions"
	"tuowei.com/common/middleware"
)

func init() {
	routerCheckRole = append(routerCheckRole, registerSysOrderRouter)
	routerNoCheckRole = append(routerNoCheckRole, registerSysOrderRouterno)
}

func registerSysOrderRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	order := apis.SysOrder{}
	r := v1.Group("/api-order").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction()).Use(middleware.CheckLogin)

	//资料，在线课程的立即购买/购物车
	r.POST("/order/buynow", order.BuyNow)
	//商品计算
	r.POST("/order/count", order.OrderCount)

	//提交资料订单
	r.POST("/add/material/order", order.AddMaterialOrder)
	//提交线上订单
	r.POST("/add/online/order", order.AddOnlineOrder)
	//app 软删订单
	//r.POST("/delete/order", order.DelOrder)

	//提交线下订单==报名
	r.POST("/add/offline/order", order.AddOfflineOrder)
	r.GET("/offlineOrderDetail/:id", order.OfflineOrderDetail)

	//我的订单列表获取
	r.POST("/get/my/order/list", order.GetMyOrderListLink)

}

func registerSysOrderRouterno(v1 *gin.RouterGroup) {
	order := apis.SysOrder{}
	r := v1.Group("/api-order")
	//资料订单付款成功，更新订单状态，收货等
	r.POST("/update/material/order", order.UpdateMaterialOrder)
	//线上订单付款成功，更新订单状态
	r.POST("/update/online/order", order.UpdateOnlineOrder)
	//app 软删订单
	r.POST("/delete/order", order.DelOrder)
	// 绑定订单和合同的地址
	//r.POST("bindContract", order.BindContract)
	// 绑定e签签署流程id
	r.POST("bindSignFlowId", order.BindSignFlowId)
}
